home *** CD-ROM | disk | FTP | other *** search
/ SGI Origin & Onyx2 Patches 1998 May / Origin and Onyx2 System Disk Patches May 1998.img / dist / patchSG0002839.idb / usr / include / sys / prctl.h.z / prctl.h
C/C++ Source or Header  |  1998-04-01  |  7KB  |  220 lines

  1. /**************************************************************************
  2.  *                                      *
  3.  *          Copyright (C) 1986-1996, Silicon Graphics, Inc.      *
  4.  *                                      *
  5.  *  These coded instructions, statements, and computer programs  contain  *
  6.  *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
  7.  *  are protected by Federal copyright law.  They  may  not be disclosed  *
  8.  *  to  third  parties  or copied or duplicated in any form, in whole or  *
  9.  *  in part, without the prior written consent of Silicon Graphics, Inc.  *
  10.  *                                      *
  11.  **************************************************************************/
  12.  
  13. /*
  14.  * prctl.h - struct for private process data area and prctl and sproc
  15.  */
  16. #ifndef __PRCTL_H__
  17. #define __PRCTL_H__
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. #ident "$Revision: 3.59 $"
  24.  
  25. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  26. /*
  27.  * PRDA area - mapped privately into each process/thread
  28.  */
  29. /* address of the process data area */
  30. #define PRDA        ((struct prda *)0x00200000L)
  31.  
  32. /* the system portion of the prda */
  33. struct prda_sys {
  34.     pid_t        t_pid;        /* epid */
  35.     __uint32_t    t_hint;        /* Share group scheduling hint */
  36.     __uint32_t    t_dlactseq;    /* Deadline scheduler activation seq# */
  37.     __uint32_t    t_fpflags;    /* Current p_fpflags (SMM, precise) */
  38.     __uint32_t    t_prid;        /* Processor type */
  39.     __uint32_t    t_dlendseq;     /* Deadline sched allocation seq # */
  40.     __uint64_t    t_unused1[5];
  41.     pid_t        t_rpid;        /* pid */
  42.     __int32_t    t_resched;    /* send pthread resched signal */
  43.     __uint32_t    t_unused[8];
  44.     
  45.     /*
  46.      * The following field is used to hold the cpu number that the
  47.      * process is currently or last ran on
  48.      */
  49.         __uint32_t    t_cpu;        /* Last/current cpu */
  50.  
  51.     /*
  52.      * The following fields are used by sigprocmask if the hold mask is
  53.      * to be in user space.
  54.      */
  55.     __uint32_t    t_flags;    /* t_hold mask is being used? */
  56.     k_sigset_t    t_hold;        /* Hold signal bit mask */
  57. };
  58.  
  59. struct prda {
  60.     char unused[2048];
  61.     union {
  62.         char fill[512];
  63.         uint32_t rsvd[8];
  64.     } sys2_prda;
  65.     union {
  66.         char fill[512];
  67.     } lib2_prda;
  68.     union {
  69.         char fill[512];
  70.     } usr2_prda;
  71.  
  72.     union {
  73.         char fill[128];
  74.         struct prda_sys prda_sys;
  75.     } sys_prda;
  76.     union {
  77.         char fill[256];
  78.     } lib_prda;
  79.     union {
  80.         char fill[128];
  81.     } usr_prda;
  82. };
  83. #define t_sys        sys_prda.prda_sys
  84.  
  85. /* Following structures used in the PR_ATTACHADDERPERM version of prctl
  86.  * which is intended mainly for use by MPI library.  First argument to
  87.  * to prctl specifies PR_ATTTACHADDRPERM, second argument points to
  88.  * prattach_args_t input parameter, third argument points to
  89.  * prattach_results_t for return values.
  90.  */
  91.  
  92. struct prattach_args_t {
  93.     __int64_t    local_vaddr;    /* local address for attach or "-1" */
  94.     __int64_t    vaddr;        /* address to be attached */
  95.     pid_t        pid;        /* process ID to be attached */
  96.     __uint32_t    prots;        /* R/W/X protections requested */
  97.     __uint32_t    flags;
  98. };
  99.  
  100. /* prattach_args_t flags values */
  101. #define    PRATTACH_ALIGN    0x1        /* align mapping offsets */
  102.  
  103. #define    PRATTACH_MASK    (PRATTACH_ALIGN)    /* allowable flags */
  104.  
  105. struct prattach_results_t {
  106.     __int64_t    local_vaddr;    /* corresponds to original vaddr */
  107.     __int64_t    region_base;    /* base address of mapped region */
  108.     __int64_t    region_size;    /* size of mapped region in byes */
  109.     __uint32_t    prots;        /* protections granted */
  110. };
  111.  
  112. #ifndef _KERNEL
  113.  
  114. /* prototypes for process control functions */
  115. #include <stddef.h>
  116. #include <sys/types.h>
  117. int blockproc(pid_t);
  118. int unblockproc(pid_t);
  119. int setblockproccnt(pid_t, int);
  120. int blockprocall(pid_t);
  121. int unblockprocall(pid_t);
  122. int setblockproccntall(pid_t, int);
  123. ptrdiff_t prctl(unsigned, ...);
  124. pid_t sproc(void (*)(void *), unsigned, ...);
  125. pid_t sprocsp(void (*)(void *, size_t), unsigned, void *, caddr_t, size_t);
  126. pid_t
  127. pidsprocsp(void (*)(void *, size_t), unsigned, void *, caddr_t, size_t, pid_t);
  128. pid_t nsproc(void (*)(void *, size_t), unsigned, void *, caddr_t, size_t);
  129.  
  130. #endif /* !_KERNEL */
  131. #endif /* (_LANGUAGE_C || _LANGUAGE_C_PLUS_PLUS) */
  132.  
  133. #if defined(_LANGUAGE_ASSEMBLY)
  134. #define PRDA        0x00200000
  135. #define T_PID        0xe00
  136. #define T_HINT        0xe04
  137. #endif
  138.  
  139. /* values for prctl */
  140. #define PR_MAXPROCS    1    /* maximum # procs per user */
  141. #define PR_ISBLOCKED    2    /* return if pid is blocked */
  142. #define PR_SETSTACKSIZE 3    /* set max stack size */
  143. #define PR_GETSTACKSIZE 4    /* get max stack size */
  144. #define PR_MAXPPROCS    5    /* max parallel processes */
  145. #define PR_UNBLKONEXEC    6    /* unblock pid on exec/exit */
  146. #define PR_SETEXITSIG    8    /* signal to be sent to share group on exit */
  147. #define PR_RESIDENT    9    /* set process immune to swapout */
  148. #define PR_ATTACHADDR    10    /* re-attach a region */
  149. #define PR_DETACHADDR    11    /* detach a region */
  150. #define PR_TERMCHILD    12    /* terminate child proc when parent exits */
  151. #define PR_GETSHMASK    13    /* retrieve share mask */
  152. #define PR_GETNSHARE    14    /* return # of members of share group */
  153. #define PR_COREPID    15    /* if process dumps core, add pid to name */
  154. #define    PR_ATTACHADDRPERM 16    /* re-attach a region, specify permissions */
  155. #define PR_PTHREADEXIT    17    /* toss a pthread without prejudice */
  156. #define PR_SETABORTSIG    18    /* signal to be sent to share group on abort */
  157.  
  158. /*
  159.  * sproc(2) sharing options
  160.  */
  161. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) || defined(_LANGUAGE_ASSEMBLY)
  162. #define PR_SPROC    0x00000001    /* doing an sproc(2) call */
  163. #define PR_SFDS        0x00000002    /* share file descriptors */
  164. #define PR_SDIR        0x00000004    /* share current/root directory */
  165. #define PR_SUMASK    0x00000008    /* share umask value */
  166. #define PR_SULIMIT    0x00000010    /* share ulimit value */
  167. #define PR_SID        0x00000020    /* share uid/gid values */
  168. #define PR_SADDR    0x00000040    /* share virtual address space */
  169. #define PR_SALL        0x0000007f    /* share all sproc(2) options */
  170.  
  171. /* nsproc(2) sharing options.  These are ignored by sproc and sprocsp. */
  172. #define PR_SSIGVEC    0x00000080    /* share signal vectors */
  173. #define PR_SPID        0x00000100    /* share PID among sprocs */
  174.  
  175. /* sproc(2) and nsproc(2) flags */
  176. #define PR_FLAGMASK    0xff000000
  177. #define PR_BLOCK    0x01000000    /* caller blocks on sproc */
  178. #define PR_NOLIBC    0x02000000    /* do not start libc arena */
  179. #define PR_PTHREAD    0x04000000    /* set appropriate attributes for
  180.                        POSIX threads. */
  181. #endif
  182.  
  183. #if defined(_LANGUAGE_FORTRAN)
  184. #define PR_SPROC    '00000001'x    /* doing an sproc(2) call */
  185. #define PR_SFDS        '00000002'x    /* share file descriptors */
  186. #define PR_SDIR        '00000004'x    /* share current/root directory */
  187. #define PR_SUMASK    '00000008'x    /* share umask value */
  188. #define PR_SULIMIT    '00000010'x    /* share ulimit value */
  189. #define PR_SID        '00000020'x    /* share uid/gid values */
  190. #define PR_SADDR    '00000040'x    /* share virtual address space */
  191. #define PR_SALL        '0000007f'x    /* share it all */
  192.  
  193. /* nsproc(2) sharing options.  These are ignored by sproc and sprocsp. */
  194. #define PR_SSIGVEC    '00000080'x    /* share signal vectors */
  195. #define PR_SPID        '00000100'x    /* share PID among sprocs */
  196.  
  197. /* sproc(2) and nsproc(2) flags */
  198. #define PR_FLAGMASK    'ff000000'x
  199. #define PR_BLOCK    '01000000'x    /* caller blocks on sproc */
  200. #define PR_NOLIBC    '02000000'x    /* do not start libc arena */
  201. #define PR_PTHREAD    '04000000'x    /* set appropriate attributes for
  202.                        POSIX threads. */
  203. #endif
  204.  
  205. /* blockproc[all](2), unblockproc[all](2), setblockproccnt[all](2) limits */
  206. #define PR_MAXBLOCKCNT     10000
  207. #define PR_MINBLOCKCNT    -10000
  208.  
  209. /*
  210.  * Flags for t_flags
  211.  */
  212. #define T_HOLD_VALID    0x1        /* Set if t_hold contains valid mask */
  213. #define    T_HOLD_KSIG_O32    0x2        /* k_sigset_t signal position */
  214.  
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218.  
  219. #endif /* __PRCTL_H__ */
  220.